<template>
	<view class="indexLayOut">

		<searchStatusBar></searchStatusBar>

		<indexBanner ref="banner"></indexBanner>

		<indexNotice ref="notice"></indexNotice>

		<indexDaysRecommend ref="daysRecommend"></indexDaysRecommend>

		<indexFeaturedTopics ref="featuredTopics"></indexFeaturedTopics>

	</view>
</template>

<script setup>
	import indexBanner from './indexBanner.vue'
	import indexNotice from './indexNotice.vue'
	import indexDaysRecommend from './indexDaysRecommend.vue'
	import indexFeaturedTopics from './indexFeaturedTopics.vue'
	import searchStatusBar from '../../components/searchStatusBar.vue'

	import {
		onLoad,
		onShow,
		onReady,
		onPullDownRefresh,
		onShareAppMessage
	} from '@dcloudio/uni-app'

	import {
		onMounted,
		ref
	} from 'vue'

	//定义四个组件，将其组件变量化
	const banner = ref(null)
	const notice = ref(null)
	const daysRecommend = ref(null)
	const featuredTopics = ref(null)

	//定义下拉刷新事件生命周期
	onPullDownRefresh(async () => {
		//index页面下拉刷新
		await banner.value.getIndexBanner()
		featuredTopics.value.getTopic()
		daysRecommend.value.getDayRecommendImg()
		notice.value.getNotice()

		uni.showToast({
			title: "数据已更新!"
		})

		uni.stopPullDownRefresh()
	})
	//此处汇报错[Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details.
	// onReady(() => {
	// 	uni.showModal({
	// 		title: "请输入密钥",
	// 		"editable": true,
	// 		"placeholderText": "密钥"
	// 	}).then(res => {
	// 		if(Boolean(res.content) === false || res.content.trim() === ""){
	// 			uni.showToast({
	// 				title:"退出功能未完成",
	// 				duration:2000,
	// 				icon:'error'
	// 			})
	// 		}else{

	// 		}
	// 	}).catch(err => {

	// 	})
	// })


	// #ifdef MP-WEIXIN
	onShareAppMessage(e => {
		console.log(e);
		return {
			title: "鲜虾米壁纸",
			path: "pages/index/index"
		}
	})

	// onShareAppMessage({
	// 	title: "鲜虾米壁纸",
	// 	path: "pages/index/index"
	// })
	// #endif
</script>

<style lang="scss" scoped>
	@mixin flexCenter {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.indexLayOut {
		width: 750rpx;
		padding-bottom: 200rpx;
		position: relative;
		background-image:
			linear-gradient(to bottom, transparent, #fff 380rpx),
			linear-gradient(to right, #bfedd6, #f5e3d9);
	}
</style>